package com.dyh.quickdemo.binjouSpring;

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import java.io.InputStream;

/*
@Author=Joey Wheeler
@Date=2021/4/26 17:11
*/
public class ClassPathFileHelper {

    public void fun(){
//        ClassLoader classLoader = this.getClass().getClassLoader();
        ClassLoader classLoader =ClassPathFileHelper.class.getClassLoader();
//        InputStream is = classLoader.getResourceAsStream(
//                "a.txt");

                InputStream is1 = classLoader.getResourceAsStream(
                "/com/dyh/quickdemo/binjouSpring/a.txt");

        InputStream is2 = classLoader.getResourceAsStream(
                "/com/dyh/quickdemo/binjouSpring/b.properties");

        InputStream is3 = classLoader.getResourceAsStream(
                "b.properties");

        InputStream is4 = classLoader.getResourceAsStream(
                "/b.properties");


        InputStream is5 = classLoader.getResourceAsStream(
                "spring-context.xml");

        InputStream is6 = classLoader.getResourceAsStream(
                "/spring-context.xml");
        System.out.println();
    }

    public static void main(String[] args) {
        ClassPathFileHelper helper = new ClassPathFileHelper();
        helper.fun();

        ClassPathResource classPathResource = new ClassPathResource("spring-context.xml");

        XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(classPathResource);

        System.out.println();
    }
}
